<template>
    <el-switch active-text="启用" inline-prompt inactive-text="禁用" v-bind="$attrs" @change="changeSwitch"
        v-model="switchState"></el-switch>
</template>
<script lang="ts">
import { shallowRef, defineComponent, watch } from 'vue';
export default defineComponent({
    name: "TableSwitch",
    props: {
        value: {
            type: String,
            default: "",
        }
    },
    setup(props) {
        const switchState = shallowRef();
        watch(() => props.value, (val: string) => {

            // switchState.value = val == '0';
            switchState.value = val == '1';
        }, { deep: true, immediate: true, })

        const changeSwitch = (val: string) => {
            // switchState.value = val == '0'
            switchState.value = val == '1';

            // return val === '1' ? '0' : '1'
        }
        return {
            changeSwitch, switchState
        }
    }
},)
</script>
